package com.aabbc.rabbitmq.controller;

import com.aabbc.rabbitmq.producer.OrderProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.time.Instant;

/**
 * ProducerController
 *
 * @author: <a href="mailto:chenfenghai@oristartech.com">chenfenghai</a>
 * @version: 1.0
 * @date: 2019-11-27 16:00
 */
@RestController
public class ProducerController {

    @Autowired
    OrderProducer orderProducer;

    @GetMapping("/test")
    public String test(){
        return "ProducerController.test" + Instant.now().toEpochMilli();
    }

    @GetMapping("/send/{message}")
    public String send(@PathVariable String message){
        if(message == null){
            message = "Hello";
        }
        orderProducer.send(message + Instant.now().toEpochMilli());
        return "success";
    }
}
